package com.cet.spring_batch_study.jobs.decorators;

import com.cet.spring_batch_study.jobs.fileRead.Player;
import lombok.AllArgsConstructor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.support.SingleItemPeekableItemReader;
import org.springframework.batch.item.support.SynchronizedItemReader;
import org.springframework.batch.item.support.builder.SingleItemPeekableItemReaderBuilder;
import org.springframework.batch.item.support.builder.SynchronizedItemReaderBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author NSOC
 */
@Configuration
public class WriterAndReaderDecorators {

    @Bean
    public SynchronizedItemReader<Player> synchronizedItemReader(ItemReader<Player> playerFlatFileItemReader) {
        return new SynchronizedItemReaderBuilder<Player>()
                .delegate(playerFlatFileItemReader)
                .build();
    }

    @Bean
    public SingleItemPeekableItemReader<Player> singleItemPeekableItemReader(ItemReader<Player> playerFlatFileItemReader) {
        return new SingleItemPeekableItemReaderBuilder<Player>()
                .delegate(playerFlatFileItemReader)
                .build();
    }

}
